Type Configuration

	Global instance:Configuration

	Field cfg:TMap
	Field strategy:ConfigurationStorageStrategy
	
	Function GetInstance:Configuration()
		If instance = Null Then
			instance = New Configuration
		End If
		Return instance
	End Function
	
	Method New()
		cfg = New TMap
	End Method
	
	Method Clear()
		cfg.Clear()
	End Method
	
	Method Load()
		If strategy = Null Then
			Return
		End If
		strategy.Load(cfg)
	End Method
	
	Method Save()
		If strategy = Null Then
			Return
		End If
		If strategy.allowSave() Then
			strategy.Save(cfg)
		End If
	End Method

	Method get:String(key:String, defaultValue:String = Null)
		If strategy = Null Then
			Return defaultValue
		End If
		Local o:Object = cfg.ValueForKey(key)
		If o = Null Then
			Return defaultValue
		End If
		Return o.ToString()
	End Method
	
	Method set(key:String, value:String)
		cfg.Insert(key, value)
	End Method

End Type